import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'
const userAccount = 'userAccount'
const userRole = 'role'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}
// 权限存在cookies
export function setPermission(data) {
  // return Cookies.set('permission', JSON.stringify(data))
  window.localStorage.permission = JSON.stringify(data)
}
export function getPermission() {
  // return Cookies.get('permission')
  return window.localStorage.permission
}
export function removePermission() {
  // return Cookies.remove('permission')
  window.localStorage.permission = ''
}
// 权限存在cookies
export function getAccount() {
  return Cookies.get(userAccount)
}
export function setAccount(useraccount) {
  return Cookies.set(userAccount, useraccount)
}
export function removeAccount() {
  return Cookies.remove(userAccount)
}
export function getRole() {
  return Cookies.get(userRole)
}
export function setRole(role) {
  return Cookies.set(userRole, role)
}
export function removeRole() {
  return Cookies.remove(userRole)
}
